package com.glory.cqaospda.viewmodel

import com.glory.cqaospda.model.TaskRepository
import com.glory.mvvmnet.base.BaseViewModel
import com.glory.mvvmnet.entity.CallObserveBean
import com.google.gson.JsonObject

class ShiftchangeModel : BaseViewModel() {

    private val repository by lazy { TaskRepository() }

    fun defaultEqpStatusChange(map: JsonObject) {

        launchOnlyResult({

            repository.defaultShift(map, "EMS_Shift")
            defUI.callObserve.value = CallObserveBean(1)
        })
    }

    fun getLoginData(user: String, password: String) {
        launchOnlyResult({
            val map = JsonObject()
            map.addProperty("UserID", user)
            map.addProperty("UserPwd", password)
            repository.login(map, "EMS_UserLogIn")
            defUI.callObserve.value = CallObserveBean(2)
        })
    }

    fun defaultLotInfo(lotID: String,EquipmentName: String) {
        val map = JsonObject()
        map.addProperty("Lotid", lotID)
        map.addProperty("EquipmentName", EquipmentName)
        map.addProperty("BatchLotType","MainLot")

        launchOnlyResult({
            val defaultLotInfo =
                repository.defaultLotInfo(map, "EMS_GetLotInfo")
            defUI.callObserve.value = CallObserveBean(3, defaultLotInfo)
        })
    }

}